jsMath

Number Theory - distribution of primes

We can ask Sage to give us all primes numbers in a given range:

prime_range(1,100) 
       
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
67, 71, 73, 79, 83, 89, 97]
len(prime_range(1,100)) 
       
25

We can also ask Sage to factor integers:

factor(100) 
       
2^2 * 5^2

The number of primes up to x is given by the functions pi(x):

prime_pi(6) 
       
3
prime_pi(10) 
       
4
prime_pi(100) 
       
25
prime_pi(50000000) 
       
3001134

We may also plot the function pi(x):

plot(prime_pi, 1, 1000, rgbcolor=(0,0,1))